package campus.aiit.ssl.controller;

import campus.aiit.ssl.domain.model.TimedTask;
import campus.aiit.ssl.service.TaskService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ihaokun
 * @date 2019/12/31 9:11
 */
@ApiIgnore()
@RestController
public class TaskController{
  @Resource private TaskService taskService;

  @GetMapping("tasks")
  private List<TimedTask> tasks() throws Throwable {
    return taskService.tasks();
  }

  @PostMapping("tasks")
  private boolean addTask(@RequestBody TimedTask task) throws Throwable {
    return taskService.addTask(task);
  }
  /*@PutMapping("tasks")
  private boolean modifyTask(@RequestBody TimedTask task){
    return taskService.saveTask(task);
  }*/
  @DeleteMapping("tasks/{id}")
  private boolean cancelTask(@PathVariable long id){
    return taskService.cancel(id);
  }
}